<?php
session_start();
require_once './config/config.php';
require_once './lib/http/HTTP.php';
require_once './lib/smarty/libs/Smarty.class.php';
require_once './app/controller/controller_ria.php';
require_once './app/controller/controller_auth.php';
require_once './app/controller/controller_bewerten.php';
require_once './app/model/model_dbhandler.php';




$smarty = new Smarty;
$contr_ria = new Ria ($smarty);
$contr_bewerten = new Bewerten(_ria_);
$smarty -> template_dir = './app/view/ria';
$smarty -> compile_dir = './lib/smarty/templates_c/ria';
$smarty -> config_dir = './lib/smarty/configs/';
$smarty -> cache_dir = './lib/smarty/cache/';

if (isset($_REQUEST["ladeRiaArt"])) {
	$contr_ria -> loadArtOverview(_ria_);
	die;
}

if (isset($_REQUEST["ladeRiaKategorie"])) {
	$contr_ria -> ladeKategorieOverview(_ria_);
	die;
}

if (isset($_REQUEST["ladeRiaKriterien"])) {
	$contr_ria -> ladeKriterienOverview($_REQUEST["id"],_ria_);
	die;
}

if (isset($_REQUEST["speicherNeueKategorie"])) {
	$contr_ria -> speicherKategorie($_REQUEST["value"], $_REQUEST["art_id"]);
	die;
}

if (isset($_REQUEST["changeWeightKriterium"])) {
	$contr_ria -> changeKriteriumWeight($_REQUEST["id"], $_REQUEST["value"]);
	die;
}

if (isset($_REQUEST["deleteKriterium"])) {
	$contr_ria -> deleteKriterium($_REQUEST["id"], $_REQUEST["art_id"]);
	die;
}

if (isset($_REQUEST["speicherNeueKriterien"])) {
	$contr_ria -> speicherKriterium($_REQUEST["value"], $_REQUEST["art_id"],_ria_);
	die;
}

if (isset($_REQUEST["speicherNeueRia"])) {
	$contr_ria -> speicherArt($_REQUEST["value"], _ria_);
	die;
}

if (isset($_REQUEST["deleteArt"])) {
	$contr_ria -> deleteRIA ($_REQUEST["id"]);
	die;
}

if (isset($_REQUEST["deleteKategorie"])) {
	$contr_ria -> deleteKategorie ($_REQUEST["id"], $_REQUEST["art_id"]);
	die;
}

if (isset($_REQUEST["addComment"])) {
	$smarty -> assign ('content', $contr_ria -> ladeComment($_REQUEST["id"]));
	$smarty -> display ('addComment.tpl');
	die;
}

if (isset($_REQUEST["saveComment"])) {
	$contr_ria -> saveComment($_REQUEST["id"], $_REQUEST["comment"]);
	die;
}


if (isset($_REQUEST["changeWeightKategorie"])) {
	$contr_ria -> changeKategorieWeight($_REQUEST["id"], $_REQUEST["value"]);
	die;
}
/////

if (isset($_REQUEST["bewerten"])) {
	$smarty -> assign ('data',$contr_bewerten -> ladeBewertung($_REQUEST["id"]));
	$smarty -> assign ("art_id", $_REQUEST["id"]);
	$smarty -> assign ('js', '<script type="text/javascript" src="public/javascript/ria/ria_bewerten.js"></script><script type="text/javascript" src="public/javascript/changeVote.js"></script>');
	$smarty -> assign ('css', '<link rel="stylesheet" type="text/css" href="public/css/ext.css" />');
	$smarty -> display('../master/head.tpl');
	$smarty -> display('ria_bewerten.tpl');
	$smarty -> display('../master/foot.tpl');
	die;
}

if (isset($_REQUEST["speicherPunkte"])) {
	$contr_bewerten -> speicherPunkte($_REQUEST["id"], $_REQUEST["value"]);
	die;
}
if (isset($_REQUEST["addCommentPunkte"])) {
	$smarty -> assign ('content' , $contr_bewerten -> ladeKommentarPunkte($_REQUEST["id"]));
	$smarty -> display('addCommentPunkte.tpl');
	die;
}

if (isset($_REQUEST["saveCommentPunkte"])) {
	$contr_bewerten -> speicherKommentarPunkte($_REQUEST["id"], $_REQUEST["comment"]);
	die;
}

//////
if (isset($_REQUEST["viewKriterien"])) {
	$smarty -> assign ("art_id", $_REQUEST["id"]);
	$smarty -> assign ('js', '<script type="text/javascript" src="public/javascript/ria/ria_kriterien.js"></script><script type="text/javascript" src="public/javascript/ria/change_ria_kategorie_weight.js"></script>');
	$smarty -> assign ('css', '<link rel="stylesheet" type="text/css" href="public/css/ext.css" />');
	$smarty -> display('../master/head.tpl');
	$smarty -> display('ria_kriterien.tpl');
	$smarty -> display('../master/foot.tpl');
	die;
}

if (isset($_REQUEST["viewKategorie"])) {
	$smarty -> assign ("art_id", $_REQUEST["id"]);
	$smarty -> assign ('js', '<script type="text/javascript" src="public/javascript/ria/ria_kategorie.js"></script><script type="text/javascript" src="public/javascript/ria/change_ria_kategorie_weight.js"></script>');
	$smarty -> assign ('css', '<link rel="stylesheet" type="text/css" href="public/css/ext.css" />');
	$smarty -> display('../master/head.tpl');
	$smarty -> display('ria_kategorie.tpl');
	$smarty -> display('../master/foot.tpl');
	die;
}


$smarty -> assign ('js', '<script type="text/javascript" src="public/javascript/ria/ria_art.js"></script>');
$smarty -> assign ('css', '<link rel="stylesheet" type="text/css" href="public/css/ext.css" />');
$smarty -> display('../master/head.tpl');
$smarty -> display('ria_uebersicht.tpl');
$smarty -> display('../master/foot.tpl');
?>